/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.brainstretch.jsf;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import org.brainstretch.models.Achievement;
import org.brainstretch.models.User;

/**
 *
 * @author mrodaitis
 */
@ManagedBean
@SessionScoped
public class ProfileController {

    @ManagedProperty("#{userController}")
    UserController userController;
    
    private User user;

    public User getUser() {
        if(user == null){
            //TODO pull this from the session
            //user = debugTestUser(10);
            user = userController.getUser();
        }
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }   
    
    public String testAchievement(){
        Achievement ach = new Achievement();
        ach.setDescription("Achievement");
        ach.setImagePath("/content/img/ach/sample");
        ach.setName("Sample Achievement");
        getUser().getAchievements().add(ach);
        return null;
    }

    public UserController getUserController() {
        return userController;
    }

    public void setUserController(UserController userController) {
        this.userController = userController;
    }
    
    public ProfileController() {
    }
}
